package cn.itlaobing.web.servlet;

import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.itlaobing.web.annotation.RequestAnnocation;
import cn.itlaobing.web.exception.MyeEXception;
import cn.itlaobing.web.model.ListModel;
import cn.itlaobing.web.model.UserModel;
import cn.itlaobing.web.service.ListService;
import cn.itlaobing.web.service.UserService;

@WebServlet(value="/listServlet/*")
public class ListServlet extends BaseServlet{
	/** 
	 * update:(查询的方法). <br/>
	 * 
	 * @author yan  
	 * @throws IOException 
	 * @throws ServletException 
	 * @since JDK 1.8 
	 */  
	@RequestAnnocation("/querymore")
	public void queryMore(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		UserModel um=(UserModel)request.getSession().getAttribute("USER");
		Integer userid=um.getId();
		System.out.println(userid);
		ListService ls=new ListService();
		List<ListModel> list=null;
		try {
			list=ls.queryOne(userid);
			System.out.println(list);
		} catch (MyeEXception e) {
			e.printStackTrace();
		}
		UserService us=new UserService();
		Date nowTime=new Date();
		System.out.println(nowTime);
		int row=0;
		try {
			row=us.updateTime(nowTime,um.getId());
		} catch (MyeEXception e) {
			e.printStackTrace();
		}
		request.getRequestDispatcher("/WEB-INF/views/userList.jsp").forward(request, response);
		request.getSession().setAttribute("LIST",list);
	}
	/** 
	 * delete:(删除的方法). <br/>
	 * 
	 * @author yan 
	 * @param request
	 * @param response 
	 * @since JDK 1.8 
	 */ 
	@RequestAnnocation("/delete")
	public void delete(HttpServletRequest request,HttpServletResponse response) {
		System.out.println("delete");		
	}
	/** 
	 * select:(查询的方法). <br/>
	 * 
	 * @author yan 
	 * @param request
	 * @param response 
	 * @since JDK 1.8 
	 */  
	@RequestAnnocation("/select")
	public void select(HttpServletRequest request,HttpServletResponse response) {
		System.out.println("select");	
		
	}
}
